<template>
    <transition name="bounce">
      <div class="lucky" v-if="visible">
        <img src="~/static/img/lucky.png" alt="Lucky"/>
        <el-button class="close" icon="el-icon-circle-close" type="text" @click="visible=false"></el-button>
      </div>
    </transition>
</template>

<script>
export default {
  name: "Lucky",
  data() {
    return {
      visible: false
    }
  },
  watch: {
    visible(val) {
      sessionStorage.lucky = val;
    }
  },
  created() {

    if (sessionStorage.lucky) {
      this.visible = sessionStorage.lucky === 'true';
    }else{
      let self = this;
      setTimeout(() => {
        self.visible = true;
      }, 1000);
    }
  }
}
</script>

<style scoped lang="less">
.lucky {
  position: fixed;
  left: 20px;
  bottom: 20px;
  width: 180px;

  img {
    max-width: 100%;
    border-radius: 5px;
  }

  .close {
    position: absolute;
    right: -20px;
    top: -12px;
  }
}
</style>
